package com.video.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.video.vo.AdminVO;

public class LoginDao {

	public AdminVO login(String user,String pass){
		AdminVO admin = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/video","root","123456");
			PreparedStatement pre = conn.prepareStatement("select * from v_admin where login_name=? and password = ?");
			pre.setString(1, user);
			pre.setString(2,pass);
			ResultSet rs = pre.executeQuery();
			if(rs.next()){
				admin = new AdminVO();
				admin.setUsername(rs.getString("user_name"));
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return admin;
	}
}
